@extends('Admin.layouts.common')

@section('content')
    <div class="container myContainer">
        <!--<button class="btn btn-info searchBtn" onclick="$('.search_box').slideToggle();">搜索/筛选</button>-->
        <a href="/theme/add_banner" class="btn btn-info searchBtn">添加幻灯片</a>
        <div class="search_box">
            <form id="search_form" method="GET">
               
                <label>
                    内容：<br>
                    <input name="key" type="text" class="form-control search_form_control" value="{{ $_search['key'] }}">
                </label>
                
                <button class="btn btn-primary" type="submit">&nbsp;&nbsp;确定&nbsp;&nbsp;</button>
            </form>
        </div>

        <div id="order_tag"></div>

        <div class="table-responsive">
            <table class="table">
                <caption>公告列表</caption>
                <thead>
                    <tr>
                        <th><a href="javascript:void(0);" data-order="id">#</a></th>
                        <th><a href="javascript:void(0);" data-order="id">图片</a></th>
                        <th><a href="javascript:void(0);" data-order="id">链接</a></th>
                        <th><a href="javascript:void(0);" data-order="title">标题</a></th>
                        <th><a href="javascript:void(0);" data-order="create_time">排序</a></th>
                        
                        <th>操作</th>
                    </tr>
                </thead>
                <tbody>
                    @forelse($list->items() as $item)
                        <tr id="tr_{{$item->id}}">
                            <td>{{ $item->id }}</td>
                            <td><img src="/{{$item->img}}" /></td>
                            <td>{{ $item->href }}</td>
                            <td>{{ $item->title }}</td>
                            <td>{{ $item->pos }}</td>
                      
                            <td>
                                <a href="/Theme/edit_banner/{{ $item->id }}">编辑</a>
                                <a href="javascript:;" onclick="ajax_delete_theme(<?=$item->id?>)">删除</a>
                            </td>
                        </tr>
                    @empty
                        <tr><td class="text-center" colspan="7">没有数据</td></tr>
                    @endforelse
                </tbody>
            </table>
            <div class="text-center">
                {{ $list->links() }}
            </div>
        </div>

    </div>
@endsection

@section('foot')
<script type="text/javascript">
$.ajaxSetup({
    headers: {
    'X-CSRF-TOKEN': $('meta[name="csrf-token"]').attr('content')
    }
})

function ajax_delete_theme(id){
    if(confirm("确定删除？")){
        $.post("/theme/ajax_delete_banner/"+id,{},function(json){
            if(json.status==1){
                $("#tr_"+json.data).fadeOut();
            }else{
                alert(json.info);
            }
        },"json");
    }
}
</script>
@endsection